package com.ym.paas;

import org.apache.commons.lang3.StringUtils;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;

public class ApplicationInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext>  {

    private String defaultServername = "server.name";

    @Override
    public void initialize(ConfigurableApplicationContext configurableApplicationContext) {

        String serName = configurableApplicationContext.getEnvironment().getProperty("server.name");
        if(StringUtils.isEmpty(serName)){
            serName = defaultServername;
        }
        System.getProperties().setProperty("server.name",serName);
    }

}
